#include <iostream>
#include "DataFrame.h"
#include <stdint.h>
#include <xgboost/c_api.h>
using namespace std;

int main(int argc, char const *argv[])
{

	text_match::DataFrame* df=new text_match::DataFrame();
	string input_text1 = "大家好";
	string input_text2 = "大家很好";
	cout<<input_text1<<" -- "<<input_text2<<endl;
	df->init_for_predict();
	cout<<"----------init end---------"<<endl;
    text_match::FeatureResult feature_result = df->predict(input_text1,input_text2);
	
	int cols=27,rows=1;//df->get_rownum();

	float test[rows][cols];
	for (int i=0;i<rows;i++){
		test[i][0] = feature_result.word_vec_mean_russellrao[i];
		test[i][1] = feature_result.char_vec_mean_russellrao[i];
		test[i][2] = feature_result.tfidf_word_sokalmichener[i];
		test[i][3] = feature_result.tfidf_word_braycurtis[i];
		test[i][4] = feature_result.tfidf_word_canberra[i];
		test[i][5] = feature_result.tfidf_word_chebyshev[i];
		test[i][6] = feature_result.word_q2_skew[i];
		test[i][7] = feature_result.word_q1_skew[i];
		test[i][8] = feature_result.char_q2_skew[i];
		test[i][9] = feature_result.char_q1_skew[i];
		test[i][10] = feature_result.word_q2_kur[i];
		test[i][11] = feature_result.word_q1_kur[i];
		test[i][12] = feature_result.char_q2_kur[i];
		test[i][13] = feature_result.char_q1_kur[i];
		test[i][14] = feature_result.len_word_text1[i];
		test[i][15] = feature_result.len_word_text2[i];
		test[i][16] = feature_result.word_match_list[i];
		test[i][17] = feature_result.char_match_list[i];
		test[i][18] = feature_result.word_vec_mean_kulsinski[i];
		test[i][19] = feature_result.char_vec_mean_kulsinski[i];
		test[i][20] = feature_result.word_vec_mean_russellrao_norm[i];
		test[i][21] = feature_result.char_vec_mean_russellrao_norm[i];
		test[i][22] = feature_result.word_vec_mean_kulsinski_norm[i];
		test[i][23] = feature_result.char_vec_mean_kulsinski_norm[i];
		test[i][24] = feature_result.word_match_list_stopword[i];
		test[i][25] = feature_result.char_match_list_stopword[i];
		test[i][26] = feature_result.tfidf_word_yule[i];
		test[i][27] = feature_result.word_levenstein[i];
		test[i][28] = feature_result.word_jaroWinkler[i];
		test[i][29] = feature_result.word_tokenSetRatio[i];
		test[i][30] = feature_result.word_partialRatio[i];
		test[i][31] = feature_result.word_partialSortRatio[i];
		test[i][32] = feature_result.word_sortRatio[i];
	}
	for (int i=0;i<rows;i++){
		for (int j=0;j<cols;j++){
		    cout<<test[i][j]<<" ";	
		}
		cout<<endl;
	}
	BoosterHandle h_booster;
    DMatrixHandle h_test;
	cout<<"start load model"<<endl;
	//XGBoosterCreate(h_test, 1, &h_booster);
	XGBoosterCreate(0, 0, &h_booster);
	XGBoosterLoadModel(h_booster,"cpp_model");

	XGDMatrixCreateFromMat((float *) test, rows, cols, -1, &h_test);
	
	bst_ulong out_len=rows;
	const float *f;
	XGBoosterPredict(h_booster, h_test, 0,0,&out_len,&f);
    
	cout<<"test end!!!!"<<endl;
	
	for (unsigned int i=0;i<out_len;i++){
		std::cout << "prediction[" << i << "]=" << f[i] << std::endl;
	}
	
    return 0;
}
